﻿using System;
using System.Data;
using System.Web.Caching;
using System.Reflection;
using DotNetNuke;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Services.Localization;


namespace gdlmo.DNN.Modules.Informations.Data
{
	public abstract class DataProvider
	{
		#region Shared/Static Methods
		// singleton reference to the instantiated object 
		private static DataProvider objProvider = null;

		// constructor
		static DataProvider()
		{
			CreateProvider();
		}

		// dynamically create provider
		private static void CreateProvider()
		{
			objProvider = ((DataProvider)DotNetNuke.Framework.Reflection.CreateObject("data", "gdlmo.DNN.Modules.Informations.Data", "gdlmo.DNN.Modules.Informations"));
		}

		// return the provider
		public static DataProvider Instance()
		{
			return objProvider;
		}

		#endregion

		#region Const Member
		protected const string TABLENAME	= "gdlmo_Informations";
		protected const string FIELDLIST	=	"*";		//"articleid";
		protected const string ORDERFIELD	="CreateDate";
		protected const string KEYFIELD	="InfoId";
		protected const string STRWHERE	="InfoId>0";
		protected const int	 ORDERTYPE	=1;					//1,降序,0,升序
		#endregion

		#region "Informations Abstract Methods"
		public abstract IDataReader GetInformations(int InfoId,int moduleId);
		public abstract IDataReader ListInformations();
		public abstract int AddInformations(int ModuleId , string Title , string URL , string Description , int ViewOrder , DateTime CreateDate , DateTime ExpireDate , string Publisher , string DeptName , DateTime PublishDate , string CreatedByUser);
		public abstract void UpdateInformations(int InfoId, int ModuleId , string Title , string URL , string Description , int ViewOrder , DateTime CreateDate , DateTime ExpireDate , string Publisher , string DeptName , DateTime PublishDate , string CreatedByUser);
		public abstract void DeleteInformations(int InfoId);
		public abstract IDataReader GetByModule(int moduleId);
		public abstract IDataReader GetPageData(int PageIndex,int PageSize);
		public abstract IDataReader GetById(int InfoId);

		#endregion
	}
}